package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.CustomerCrsReport;
import com.ruoyi.bizsys.service.ICustomerCrsReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户CRS征信Controller
 *
 * @author african-loan
 * @date 2021-12-30
 */
@RestController
@RequestMapping("/bizsys/customer_crs_report")
public class CustomerCrsReportController extends BaseController {
    @Autowired
    private ICustomerCrsReportService customerCrsReportService;

/**
 * 查询用户CRS征信列表
 */
@PreAuthorize("@ss.hasPermi('bizsys:customer_crs_report:list')")
@GetMapping("/list")
        public TableDataInfo list(CustomerCrsReport customerCrsReport) {
        startPage();
        List<CustomerCrsReport> list = customerCrsReportService.selectCustomerCrsReportList(customerCrsReport);
        return getDataTable(list);
    }
    
    /**
     * 导出用户CRS征信列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:customer_crs_report:export')")
    @Log(title = "用户CRS征信", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CustomerCrsReport customerCrsReport) {
        List<CustomerCrsReport> list = customerCrsReportService.selectCustomerCrsReportList(customerCrsReport);
        ExcelUtil<CustomerCrsReport> util = new ExcelUtil<CustomerCrsReport>(CustomerCrsReport.class);
        return util.exportExcel(list, "customer_crs_report");
    }

    /**
     * 获取用户CRS征信详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:customer_crs_report:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(customerCrsReportService.selectCustomerCrsReportById(id));
    }

    /**
     * 新增用户CRS征信
     */
    @PreAuthorize("@ss.hasPermi('bizsys:customer_crs_report:add')")
    @Log(title = "用户CRS征信", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerCrsReport customerCrsReport) {
        return toAjax(customerCrsReportService.insertCustomerCrsReport(customerCrsReport));
    }

    /**
     * 修改用户CRS征信
     */
    @PreAuthorize("@ss.hasPermi('bizsys:customer_crs_report:edit')")
    @Log(title = "用户CRS征信", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerCrsReport customerCrsReport) {
        return toAjax(customerCrsReportService.updateCustomerCrsReport(customerCrsReport));
    }

    /**
     * 删除用户CRS征信
     */
    @PreAuthorize("@ss.hasPermi('bizsys:customer_crs_report:remove')")
    @Log(title = "用户CRS征信", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(customerCrsReportService.deleteCustomerCrsReportByIds(ids));
    }
}
